package com.huawei.M01.iterator.May09;

import java.util.HashMap;
import java.util.Map;

/**
 * 计算时间数量
 *
 * @author zhiwu
 */
public class CountTime {
    public int countTime(String time) {
        String[] times = time.split(":");

        int hourNum = dealHour(times[0]);
        int minNum = dealMin(times[1]);

        return hourNum * minNum;
    }

    private int dealMin(String time) {
        String[] split = time.split("");
        int res = 1;
        if (split[0].equals("?")) {
            res *= 6;
        }
        if (split[1].equals("?")) {
            res *= 10;
        }
        return res;
    }

    private int dealHour(String time) {

        String[] split = time.split("");
        if (split[0].equals("?") && split[1].equals("?")) {
            return 24;
        }
        if ((split[0].equals("0") || split[0].equals("1")) && split[1].equals("?")) {
            return 10;
        }

        if (split[0].equals("2") && split[1].equals("?")) {
            return 4;
        }
        if (split[0].equals("?") && Integer.parseInt(split[1]) <= 3) {
            return 3;
        }
        if (split[0].equals("?")) {
            return 2;
        }
        return 1;
    }
}
